#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=2e5+10;
int n,m,head=1,tail;
struct node
{
	int num,i;
}q[MAXN];
void insert(int x,int i)
{
	while(tail-head>=m||q[head].i<=i-m)++head;
	while(head<=tail&&q[tail].num<x)--tail;
	q[++tail]=(node){x,i};
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<m;++i)
	{
		int x;
		scanf("%d",&x);
		insert(x,i);
	}
	for(int i=m;i<=n;++i)
	{
		int x;
		scanf("%d",&x);
		insert(x,i);
		printf("%d\n",q[head].num);
	}
	return 0;
}
